#include "myuart.h"

/* 自己的初始化波特率函数，方便配置 */
void MyUART1_Init(uint32_t BaudRate)
{
  huart1.Instance = USART1;
  huart1.Init.BaudRate = BaudRate;
  huart1.Init.WordLength = UART_WORDLENGTH_8B;
  huart1.Init.StopBits = UART_STOPBITS_1;
  huart1.Init.Parity = UART_PARITY_NONE;
  huart1.Init.Mode = UART_MODE_TX_RX;
  huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
  huart1.Init.OverSampling = UART_OVERSAMPLING_16;
  HAL_UART_Init(&huart1);
}

uint8_t rx_data;
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
    if(huart == &huart1)
    {
        HAL_UART_Transmit(&huart1,&rx_data,1,200);      /*将接收到的数据发送出去*/
        HAL_UART_Receive_IT(&huart1,&rx_data,1);        /*接收下一字节数据*/
    }

}